﻿using System.Data;
using EntitiesTM;
using System.Data.SqlClient;

namespace DataAccess
{
    public class DaResultUnit
    {
        public DataTable selAllResultUnit(string companyid)
        {
            string strCommandText = "selAllResultUnit"+companyid;
            return SqlHelper.ExecuteData(CommandType.StoredProcedure, strCommandText, null);
        }

        public void insResultUnit(EnResultUnit resultUnit, string companyid)
        {
            string strCommandText = "insResultUnit" + companyid;
            SqlParameter[] paraLocal = new SqlParameter[3];
            paraLocal[0] = new SqlParameter("@ResultUnitName", resultUnit.resultUnitName);
            paraLocal[1] = new SqlParameter("@ResultUnitDescription", resultUnit.resultUnitDescription);
            paraLocal[2] = new SqlParameter("@ResultUnitNameAlt", resultUnit.resultUnitNameAlt);
            SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, strCommandText, paraLocal);
        }

        public void updResultUnit(EnResultUnit resultUnit, string companyid)
        {
            string strCommandText = "updResultUnit" + companyid;
            SqlParameter[] paraLocal = new SqlParameter[4];
            paraLocal[0] = new SqlParameter("@ResultUnitName", resultUnit.resultUnitName);
            paraLocal[1] = new SqlParameter("@ResultUnitDescription", resultUnit.resultUnitDescription);
            paraLocal[2] = new SqlParameter("@ResultUnitNameAlt", resultUnit.resultUnitNameAlt);
            paraLocal[3] = new SqlParameter("@ResultUnitID", resultUnit.resultUnitID);
            SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, strCommandText, paraLocal);
        }

        public void delResultUnit(EnResultUnit resultUnit, string companyid)
        {
            string strCommandText = "delResultUnit" + companyid;
            SqlParameter[] paraLocal = new SqlParameter[1];
            paraLocal[0] = new SqlParameter("@ResultUnitID", resultUnit.resultUnitID);
            SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, strCommandText, paraLocal);
        }
    }
}
